# -*- coding: utf-8 -*-
import numpy as np
#初始化灰度图像
def rgb2black(image):
    max_gray=np.zeros(image.shape[0:2],dtype='uint8')
    avg_gray=np.zeros(image.shape[0:2],dtype='uint8')
    weigth_gray=np.zeros(image.shape[0:2],dtype='uint8')
    for ii in range(image.shape[0]):
        for jj in range(image.shape[1]):
            r,g,b=image[ii,jj,:]
            #最大值灰度化方法
            max_gray[ii,jj]=max(r,g,b)
            #平均值灰度化方法
            avg_gray[ii,jj]=(r+b+g)/3
            #加权平均灰度化方法
            weigth_gray[ii,jj]=0.30*r+0.59*g+0.11*b
    return max_gray,avg_gray,weigth_gray